package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.OfferRecord;

@Repository
public interface OfferRecordDao extends JpaRepository<OfferRecord, Integer>, JpaSpecificationExecutor<OfferRecord> {

	@Query("from OfferRecord where educationalRequire = ?1")
	List<OfferRecord> find(String name);

	@Query("from OfferRecord where educationalRequire like ?1")
	List<OfferRecord> findLike(String name);

	@Query(value = "select * from OfferRecord limit ?, ?", nativeQuery = true)
	List<OfferRecord> findPage(Integer offset, Integer size);

	@Query(value = "select * from OfferRecord where educationalRequire = ? limit ?, ?", nativeQuery = true)
	List<OfferRecord> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from OfferRecord where educationalRequire like ? limit ?, ?", nativeQuery = true)
	List<OfferRecord> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from OfferRecord where educationalRequire = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from OfferRecord where educationalRequire like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from OfferRecord order by id asc")
	List<OfferRecord> findAllAsc();
}

